/*
 * Copyright (c) 2009, Jan Pastor. All Rights Reserved.
 */

package sk.jp.jitag.dao.db4o;

import java.lang.annotation.Documented;
import java.lang.annotation.Target;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

import com.db4o.config.ObjectField;
import com.db4o.ext.ObjectCallbacks;
import com.db4o.ObjectContainer;

/**
 * Set up flag of field that cascading delete can be performed.
 * <p>Use this annotation carrefully. It is recommended to implement method
 * {@link ObjectCallbacks#objectCanDelete(ObjectContainer)} that checks if
 * instance can be deleted (no remaining references, etc.). 
 * <p>See {@link ObjectField#cascadeOnDelete(boolean)} method
 * documentation for details.
 * <p><b>From ref. doc.:</b><br>
 * Db4o does not have a built-in referential integrity checking mechanism. Luckily
 * EventRegistry gives you access to all the necessary events to implement it. You
 * will just need to trigger validation on create, update or delete and cancel the
 * action if the integrity is going to be broken.<br>
 * For example, if Car object is referencing Pilot and the referenced object should
 * exist, this can be ensured with the following handler in deleting() event.
 */
@Documented
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface CascadeOnDelete {
}